package ru.ksu.ktk.diploma.sdi.bean;

import ru.ksu.ktk.diploma.sdi.model.DescriptionFile;

import javax.faces.context.FacesContext;
import javax.faces.context.ExternalContext;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: coldflame
 * Date: 21.12.2008
 * Time: 22:30:12
 * To change this template use File | Settings | File Templates.
 */
public class SearchResultsBean {
    private List<DescriptionFile> sources = new ArrayList<DescriptionFile>();
    private String searchText;

    public List<DescriptionFile> getSources() {
        for (int i = 0; i < 10; i++) {
            sources.add(new DescriptionFile(i + ".xml"));
        }
        return sources;
    }

    public String getSearchText() {
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
        HttpServletRequest request = (HttpServletRequest) context.getRequest();
        SearchBean searchBean = (SearchBean) request.getAttribute("searchBean");
        searchText = searchBean.getText();
        return searchText;
    }

    public void setSources(List<DescriptionFile> sources) {
        this.sources = sources;
    }

}
